package com.Nuyoah.demo01.controller;


import com.Nuyoah.demo01.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MailController {
    @Autowired
    MailService service;//注入刚才写好的MailService

    //使用yaml文件中的from数据
    @Value("${spring.mail.username}")
    private String from;

    @GetMapping("/mail")//等同于@RequestMapping(method = RequestMethod.GET)
    public String sendmail() {
        service.sendmail(from, "2832315269@qq.com",
                "会议通知", "请于下午三点在1号会议室参加民主生活会");
        return "邮件发送成功！";
    }
}
